from datetime import datetime
from typing import Dict, Optional
from loguru import logger
from services.data_view_plugin_service import DataViewPluginService
from config.settings import settings


class OptionsVolatilityModel:
    
    def __init__(self):
        self.data_service = DataViewPluginService()

    def get_underlying_symbols(self) -> Dict[str, str]:
        """获取标的符号配置"""
        return settings.options_underlying_symbol_config

    def get_options_skew_data(self, underlying_symbol: str, target_date: str) -> Optional[Dict]:
        """获取期权波动率偏斜数据"""
        return self.data_service.get_options_skew_data(underlying_symbol, target_date)

    def get_options_atm_historical_iv(self, underlying_symbol: str, start_date: str, end_date: str, option_class: str) -> Optional[Dict]:
        """获取期权平值历史隐含波动率"""
        return self.data_service.get_options_atm_historical_iv(underlying_symbol, start_date, end_date, option_class)

    def get_iv_history(self, underlying_symbol: str, start_date: str, end_date: str) -> Optional[list]:
        """获取期权隐含波动率历史数据"""
        return self.data_service.get_iv_history(underlying_symbol, start_date, end_date)

    def get_options_cone_data(self, underlying_symbol: str, target_date: str) -> Optional[Dict]:
        """获取期权波动率锥数据"""
        return self.data_service.get_options_cone_data(underlying_symbol, target_date)

    def get_options_iv_surface_data(self, underlying_symbol: str, date: str, option_class: str) -> Optional[list]:
        """获取期权隐含波动率3D曲面数据"""
        return self.data_service.get_options_iv_surface_data(underlying_symbol, date, option_class)

    def get_default_date(self) -> str:
        """获取默认日期"""
        return datetime.now().strftime('%Y-%m-%d')